package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 1.导入依赖: mysql / durid / mybatis / mybatis-spring / spring-context / spring-jdbc
 * 2.配置mybatis
 * 3.核心配置类导入mybatis配置类
 * 4.写一个pojo/mapper findByID方法
 * 5.测试
 */
public class MybatisApp {
    public static void main(String[] args) {
        //1.解析核心配置文件  获得容器
        ApplicationContext app = new AnnotationConfigApplicationContext(SpringConfig.class);
        //2.获得mapper bean
        UserMapper mapper = app.getBean(UserMapper.class);
        //3.查数据
        User user = mapper.findById(1);
        System.out.println(user);
    }
}
